/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds.ui;

import java.awt.Component;
import java.awt.image.BufferedImage;
import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeNode;
import net.worlds.AssetManager;


public class ObjectListCellRenderer extends DefaultListCellRenderer{

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int idx, boolean sel, boolean hasFocus)
    {
        super.getListCellRendererComponent(list, value, idx, sel, hasFocus);
        String objectType = (String) value;
        BufferedImage image = AssetManager.getImage(objectType);
        if(image == null)
            image = AssetManager.getImage("Unknown");
        setIcon(new ImageIcon(image));
        return this;
    }
}
